using System;
using System.Collections.Generic;
using System.Text;
using ACS.Compiler.Util;

namespace ACS.Compiler.Tables
{
    public class CodeTable 
    {
        private static CodeTable _instance;
        public static CodeTable Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new CodeTable();
                }
                return _instance;
            }
        }

        private Dictionary<string, CodeBase> _table = new Dictionary<string, CodeBase>();

        public Dictionary<string, CodeBase> Table
        {
            get { return _table; }
        }

        public void AddCodeBase(CodeBase codeBase)
        {
            string key = codeBase.Namespace;
            if (_table.ContainsKey(key))
            {
                Logger.Instance.TraceError("file with this name is already parsed.");
            } else
            {
                _table.Add(key, codeBase);  
            }
        }   
    }
}
